<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
   <%@ include file="/common/CimsCommon.jsp" %>
  <title>历史未匹配债权查询</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <script type="text/javascript" src="${basePath}/js/cims/publicJs/cascadeSelect.js"></script>
  <script type="text/javascript" src="<%=basePath%>/js/cims/creditManage/contractMassage.js"></script>
<!-- 相关js方法 -->
<script type="text/javascript">
	//页面加载完后 
	$(document).ready(function(){
		initFn();
	});
	 
	 
	//定时任务 页面触发
	function viewData(vId,exeStatus){
		if("2"==exeStatus){
		    art.dialog({title: '提示', content: '选择的数据状态为“处理完成”，不允许再次处理！', ok: function () {return true; }, icon: 'warning', lock:true, background:'#600', opacity: 0.10});
			//alert("选择的数据状态为“处理完成”，不允许再次处理！");
			return;
		}
		var url = "${basePath}loggerhistory/batchSettleAndSecondBuy?id="+vId;
		//if(confirm("确认处理结算和二次购买吗？")){
		//	window.location = url;
		//}
		/* if(confirm("确认处理结算和二次购买吗？")){
        jyAjax(url,null,function(result){
			alert(result.msg);
			queryData();
		})
       } */
       
       art.dialog({title: '询问', content: '确认处理结算和二次购买吗？', ok: function () {
		  jyAjax(url,null,function(result){
				//alert(result.msg);
				 var icon = "warning";
				 if(result.status=="ok"){icon = "succeed"; }else if(result.status=="error"){icon = "error"; }
				art.dialog({title: '处理结果', content: result.msg, ok: function () {return true; }, lock:true, background:'#600', opacity: 0.10, icon: icon});
				queryData();
			});
		}, cancel: true, icon: 'question', lock:true, background:'#600', opacity: 0.10});
		
	}
	
	// 页面触发 重置数据
	function delviewData(vId,exeStatus){
		if("2"!=exeStatus){
			//alert("选择的数据状态不为“处理完成”，不允许重置！");
			art.dialog({title: '提示', content: '选择的数据状态不为“处理完成”，不允许重置！', ok: function () {return true; }, icon: 'warning', lock:true, background:'#600', opacity: 0.10});
			return;
		}
		var url = "${basePath}loggerhistory/delSettleAndSecondBuy?id="+vId;
		//if(confirm("确认重置结算和二次购买吗？")){
		//	window.location = url;
		//}
		/* if(confirm("确认重置结算和二次购买吗？")){
        jyAjax(url,null,function(result){
			alert(result.msg);
			queryData();
		})
	   } */
	   
	   art.dialog({title: '询问', content: '重置会将处理后的数据恢复到未处理前,您确认要重置结算和二次购买吗？', ok: function () {
		  jyAjax(url,null,function(result){
				//alert(result.msg);
				 var icon = "warning";
				 if(result.status=="ok"){icon = "succeed"; }else if(result.status=="error"){icon = "error"; }
				art.dialog({title: '处理结果', content: result.msg, ok: function () {return true; }, lock:true, background:'#600', opacity: 0.10, icon: icon});
				queryData();
			});
		}, cancel: true, icon: 'question', lock:true, background:'#600', opacity: 0.10});
	}
	
	// 新增  结算和二次购买 周鹏 2015-11-10
	function addSettleAndSecondBuy(){
		var cooperorgCode = $("#cooperorgCode").val();
		var contractCode = $("#contractCode").val();
		var creditPackageName = $("input[name=creditPackageName]").val();
		var settleDate = $("input[name=settleDate]").val();

		//新增   字段不能为空
		if(null==cooperorgCode ||""==cooperorgCode){
			//alert("请选择合作机构！");
			art.dialog({title: '提示', content: '请选择合作机构！', ok: function () {return true; }, icon: 'warning', lock:true, background:'#600', opacity: 0.10});

			return;
		}
		if(null==contractCode ||""==contractCode){
			//alert("请选择合约名称！");
			art.dialog({title: '提示', content: '请选择合约名称！', ok: function () {return true; }, icon: 'warning', lock:true, background:'#600', opacity: 0.10});
			
			return;
		}
		if(null==creditPackageName ||""==creditPackageName){
			//alert("请选择债权包名称！");
			art.dialog({title: '提示', content: '请选择债权包名称！', ok: function () {return true; }, icon: 'warning', lock:true, background:'#600', opacity: 0.10});
			return;
		}
		if(null==settleDate ||""==settleDate){
			//alert("请选择结算时间！");
			art.dialog({title: '提示', content: '请选择结算时间！', ok: function () {return true; }, icon: 'warning', lock:true, background:'#600', opacity: 0.10});
			return;
		}
		
		var url = "${basePath}loggerhistory/insertSettleAndSecondBuy?cooperorgCode=" + cooperorgCode+ "&contractCode="+contractCode+"&creditPackageName="+creditPackageName+"&settleDate="+settleDate;
		//if(confirm("确认重置结算和二次购买吗？")){
		//	window.location = url;
		//}
		
		art.dialog({title: '询问', content: '确认新增结算和二次购买吗？', ok: function () {
		  jyAjax(url,null,function(result){
				//alert(result.msg);
				var icon = "warning";
			    if(result.status=="ok"){icon = "succeed"; }else if(result.status=="erro"){icon = "error"; }
				art.dialog({title: '处理结果', content: result.msg, ok: function () {return true; }, lock:true, background:'#600', opacity: 0.10, icon: icon});
				queryData();
			});
		}, cancel: true, icon: 'question', lock:true, background:'#600', opacity: 0.10});
		
		/* if(confirm("确认新增结算和二次购买吗？")){
			jyAjax(url,null,function(result){
				alert(result.msg);
				queryData();
			})
		} */
  }

  //实时生成还款计划和结算计划 zhoupeng 2016-5-12
function dealSettleAndSecondBuy(){
    var settleDate = $("input[name=settleDate]").val();
    if(null==settleDate ||""==settleDate){
			//alert("请选择结算时间！");
			art.dialog({title: '提示', content: '请选择结算时间！', ok: function () {return true; }, icon: 'warning', lock:true, background:'#600', opacity: 0.10});
			return;
	}
	var url = contextRootPath+"/creditsettlebill/dealSettleAndSecondBuy?"+"&settleDate="+settleDate;;
	art.dialog({title: '询问', content: '确认批量结算和二次购买吗？', ok: function () {
		  jyAjax(url,null,function(result){
				//alert(result.msg);
			    var icon = "warning";
			    if(result.status=="ok"){icon = "succeed"; }else if(result.status=="error"){icon = "error"; }
				art.dialog({title: '处理结果', content: result.msg, ok: function () {return true; }, lock:true, background:'#600', opacity: 0.10, icon: icon,width: 450});
				queryData();
			});
		}, cancel: true, icon: 'question', lock:true, background:'#600', opacity: 0.10});
		
	
	/*if(confirm("您确认要发送数据吗？")){
      $.ajax({
          type:"POST",
          dataType : "json",
          url:contextRootPath+"/creditsettlebill/AsynSettleAndSecondBuyAll",
          success:function(msg){
          	alert(msg.msg);
          	var v_status = msg.status;
          }
      });
  }*/
}
  
</script>
 
</head>
<body style="background-color:#FFFFFF">

	<div id="resizable" class="resizable ui-widget-content ui-corner-all">
	  <div id="toolbar"> </div>
	  <div class="ui-wid  get-content ui-corner-all" style="padding:10px;" id="formDiv"></div>
	  <div id="table" class="tableSpan"></div>
	</div>
	<!-- 页面初始化 需要的 div -->
	<div id="content"></div>
	  <!-- 列表按钮操作 start -->
	<div id="tableToolbar" class="tableToolbar" style="display:none;">
	  </div>
	  <!--  列表按钮操作 end -->
	</div>

</body>
<!-- 相关js方法 -->	
<script>
	var iframe;
	
	//定义form表单 查询 方法
	function queryData(){
	    var startDate = $("input[name=startDate]").val();
	    // if(startDate==null||startDate==""){
	    //	alert("账单日不能为空！");
	    //	return ;
	    //}
		iframe.iframeObj["table"].query();
	}
	//定义 form表单 重置方法
	function resetData(){
		iframe.iframeObj["form"].reset();
		$("select[name=cooperorgCode]").newCascadeObject();
	}
	

	//初始化 查询页面元素
	function initFn(){
		//定义 form表单查询 信息
		 var formStructure={
			// 定义form表单 字段信息
			columns : [
	         {display : ' 合作机构 ', code : 'cooperorgCode', width : 200,  type:'text'},
	         {display : ' 合约名称 ', code : 'contractCode', width : 200,  type:'text'},
	         {display : ' 债权包名称 ', code : 'creditPackageName', width : 200,  type:'text'}
			],
			//定义form 表单 按钮信息
			buttons:[
			 {"text":"查询","fun":queryData,icon:"ui-icon-search"},
			 {"text":"重置","fun":resetData,icon:"ui-icon-extlink"}
			]
		}
		//定义工具条	
		var toolbar={
			title:"查询列表"
		}
		//定义 table 列表信息	
		var tableStructure = {
			//定义table 列表的表头信息
			columns : [
			{display : ' 合作机构名称 ', code : 'cooperorgCode', width : 150, align : 'left', type:'select', isOrder : false,
			 value: <syscode:dictionary  codeType="cooperorgCodes" 	type="json"	/>},
			{display : ' 合约编号 ', code : 'contractCodeName', width : 150, align : 'left', type:'text', isOrder : false},
			{display : ' 债权包名称 ', code : 'creditPackageName', width : 150, align : 'left', type:'text', isOrder : false},
			{display : ' 异常应匹配金额合计 ', code : 'matchAmount', width : 120, align : 'right', type:'text', isOrder : false},
			{display : ' 异常应返还金额合计 ', code : 'returnAmount', width : 120, align : 'right', type:'text', isOrder : false}
		   ],
			url : "${basePath}loggerhistory/queryLoggerHistoryTotalList",
			toolbar:"tableToolbar",
			pageSize : 10,
			selectType : 'checkbox',
			isCheck : false,
			rownumbers : true,
			pages : [ 10, 20, 30 ],
			trHeight : 30,
			primaryKey:"id"
		};
		//组装 searchIframe 的相关参数		
		var searchIframe={"toolbar":toolbar,"form":formStructure,"table":tableStructure};	
		//初始化 form 表单 table 列表 及工具条 
		iframe=$("#content").newSearchIframe(searchIframe);
		iframe.show();
	}
</script> 
</html>
